<?php

namespace App\Http\Controllers\admin\system;

use App\Http\Controllers\Controller;
use App\Models\order\OrderModel;
use App\Models\product\ProductModel;
use App\Models\users\UsersNewProductRecordModel;
use Illuminate\Http\JsonResponse;
use lxs\api\ApiResponse;

class StatisticsController extends Controller
{

    /**
     * 后台首页统计
     */
    public function getHomeStatisticsData(): JsonResponse
    {

        $getLaxinNum = UsersNewProductRecordModel::count();

        $getLaxinOrderNum = OrderModel::where('order_status', 1)->count();

        $getLaxinOrderRefundNum = OrderModel::where('order_status', 4)->count();

        $getProductNum = ProductModel::where('deleted_at', 0)->count();

        $getData = [
            'getLaxinNum' => $getLaxinNum,
            'getLaxinOrderNum' => $getLaxinOrderNum,
            'getLaxinOrderRefundNum' => $getLaxinOrderRefundNum,
            'getProductNum' => $getProductNum,
        ];

        return ApiResponse::apiResponseData(200, '后台首页统计成功', [
            'getData' => $getData
        ]);

    }

}
